package com.ios.palette.service.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.ios.palette.dao.IBaseDAO;
import com.ios.palette.service.IBaseService;
@Service
@Cacheable(value="base")
public class BaseServiceImpl<T> implements IBaseService<T>{
	@Autowired
	private IBaseDAO<T> baseDAO;
	
	public Serializable add(T t) {
		// TODO Auto-generated method stub
		return baseDAO.save(t);
	}

	public T get(Class<T> entityClass,Serializable id) {
		// TODO Auto-generated method stub
		return baseDAO.findById(entityClass,id);
	}

	public List<T> list(Class<T> entityClass) {
		// TODO Auto-generated method stub
		return baseDAO.findAll(entityClass);
	}

	public void update(T t) {
		// TODO Auto-generated method stub
		baseDAO.update(t);
	}

	public void delete(T t) {
		// TODO Auto-generated method stub
		baseDAO.delete(t);
	}
	@Override
	public List<T> sortDesc(Class<T> entityClass, String order) {
		// TODO Auto-generated method stub
		return baseDAO.findOrderByDesc(entityClass, order);
	}
	@Override
	public void delete(Class<T> entityClass, Long id) {
		// TODO Auto-generated method stub
		baseDAO.delete(entityClass, id);
	}

}
